package com.liuhung.ash.weixin.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liuhung.ash.weixin.api.core.WxDefaultHandler;
import com.liuhung.ash.weixin.entity.Mpact;
import com.liuhung.ash.weixin.web.WxSpringSupport;

@Controller
@RequestMapping("/wx/xbfc")
public class XnController extends WxSpringSupport{
	private final static Logger log= Logger.getLogger(XnController.class);
	 @Override
	    protected void init() {
	        Mpact Mpact = new Mpact();
	        // 修改为实际的公众号信息,可以在开发者栏目中查看
	        Mpact.setApp_id("wx7cc972d0c0992f4f");
	        Mpact.setApp_secret("79c13bbc696c5ac0da1a4b72c726abca");
	        Mpact.setToken("xibeifdccs");
	        Mpact.setAes_key("8w3FgLnwvJTHxftp5Mz0GnpNJQLn98qiHTtcMN8VNqb");
	        this.setMpact(Mpact);
	        // 可实现自己的WxHandler
	        this.setWxHandler(new WxDefaultHandler());
	    }
	    @RequestMapping(value = "",produces = {"text/plain;charset=UTF-8"})
	    @ResponseBody
	    public String wxCore(HttpServletRequest req) {
	        String reply = "";
	        try {
	            reply = wxInteract(req);
	        } catch (IOException e) {
	            log.error(e.getLocalizedMessage(), e);
	        }
	        return reply;
	    }
}
